#include<linux/module.h>
#include<linux/init.h>
MODULE_LICENSE("GPL");
static int __init symbol_put_addr_init(void);
static void __exit symbol_put_addr_exit(void);

int __init symbol_put_addr_init(void)
{
	const char *symbol_name;
	const char *mod_name;
	struct module *fmodule;
	void * addr;

	symbol_name = "symbol_A";
	addr = __symbol_get(symbol_name);

	if(addr != NULL)
	{
		printk("addr : %lx \n",(unsigned long)addr);	
		mod_name="test_module";
		fmodule=find_module(mod_name);
		if(fmodule != NULL)
		{
			printk("before calling symbol_put_addr,\n");	
			printk("refs of %s is: %d\n",mod_name,module_refcount(fmodule));
			symbol_put_addr(addr);
			printk("after calling symbol_put_addr,\n");
			printk("refs of %s is: %d\n",mod_name,module_refcount(fmodule));
		}
		else
		{
			printk("find %s failed!\n",mod_name);	
		}
	}
	else
	{
		printk("%s isn't found\n",symbol_name);	
	}
	return 0;
}
void __exit symbol_put_addr_exit(void)
{
	printk("module exit ok!\n");
}
module_init(symbol_put_addr_init);
module_exit(symbol_put_addr_exit);
